<?php

class m131021_133640_change_contact_table extends CDbMigration
{
	public function up()
	{
            $this->execute("
                ALTER TABLE  `contacts` DROP  `city` ,
                    DROP  `state` ,
                    DROP  `zipcode` ,
                    DROP  `star` ,
                    DROP  `categoryId` ;
                ALTER TABLE  `contacts` CHANGE  `services_offered`  `content` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ;
                ALTER TABLE  `contacts` CHANGE  `image`  `fileId` INT NOT NULL ;
                ALTER TABLE  `contacts` CHANGE  `fileId`  `fileId` INT( 11 ) NULL DEFAULT  '0';
                ALTER TABLE  `contacts` ADD  `userName` VARCHAR( 255 ) NOT NULL AFTER  `company_name` ,
                                        ADD  `regency` VARCHAR( 255 ) NULL AFTER  `userName` ,
                                        ADD  `email` VARCHAR( 255 ) NOT NULL AFTER  `regency` ;
                ALTER TABLE  `contacts` ADD  `title` VARCHAR( 255 ) NOT NULL AFTER  `email` ,
                                        ADD  `fax` VARCHAR( 20 ) NULL AFTER  `title` ;
                ALTER TABLE  `contacts` CHANGE  `company_name`  `companyName` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL ;
                ALTER TABLE  `contacts` ADD  `createTime` INT NOT NULL AFTER  `status` ;
                ALTER TABLE  `file` DROP  `fileId` ,
                                    DROP  `file` ,
                                    DROP  `size` ,
                                    DROP  `status` ;
                ALTER TABLE  `file` CHANGE  `url_file`  `url` VARCHAR( 250 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL ;
                ALTER TABLE  `file` ADD  `contentId` INT NOT NULL AFTER  `url` ,
                                    ADD  `contentType` TINYINT NOT NULL AFTER  `contentId` ;
                ALTER TABLE  `file` ADD  `createTime` INT NOT NULL ;
                ALTER TABLE  `contacts` DROP  `fileId` ;
            ");
	}

	public function down()
	{
		echo "m131021_133640_change_contact_table does not support migration down.\n";
		return false;
	}

	/*
	// Use safeUp/safeDown to do migration with transaction
	public function safeUp()
	{
	}

	public function safeDown()
	{
	}
	*/
}